import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-08-09
 * Time: 14:22
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       // 这里一定要注释掉，否则页面状态码：405 super.doGet(req, resp);

        // 这是在服务器的控制台中，打印字符串（服务器能看到，客户端看不到）
        System.out.println("hello world");

        // 这里是给resp的body写入hello world 字符串，这个内容会被HTTP响应返回给服务器，显示到浏览器界面
        resp.getWriter().write("Hello world");
    }
}
